#include <iostream>
#include <vector>
#include <queue>

using namespace std;

const int N = 1e5+10;
int n;
vector<int> edges[N];
int fa[N];
int dist[N];

// 深度 
int dfs(int u)
{
    int ret = 0;
    for(auto v: edges[u])
    {
        ret = max(ret,dfs(v));
    }
    return ret + 1;
}

// 宽度
int bfs()
{
    int ret = 0;
    queue<int> q;
    q.push(1);
    while(q.size())
    {
        int sz = q.size();
        ret = max(ret,sz);
        while(sz--)
        {
            int u = q.front();q.pop();
            for(auto v:edges[u])
            {
                q.push(v);
            }
        }
    }
    return ret;
}

int main()
{
    cin >> n;
    for(int i = 1;i < n;i++)
    {
        int a,b;
        cin >> a >> b;
        edges[a].push_back(b);
        fa[b] = a;
    }    

    // 深度
    cout << dfs(1) << endl;

    // 宽度
    cout << bfs() << endl;

    // 距离
    int x,y;
    cin >> x >> y;
    while(x != 1)
    {
        dist[fa[x]] = dist[x] + 1;
        x = fa[x];
    }

    int len = 0;
    while(y != 1 && dist[y] == 0)// dist[y] == 0 --> y没有经过相遇点
    {
        len++;
        y = fa[y]; 
    }

    cout << dist[y] * 2 + len << endl;
    return 0;
}